package cc.wsyw126.java.lintCode;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class HowManyNumberInOneLine {
    int x, y;

    public HowManyNumberInOneLine() {
    }

    public HowManyNumberInOneLine(int a, int b) {
        x = a;
        y = b;
    }

    public static void main(String[] args) {
        int[][] count = new int[21][21];
        int max = 1;
        for (int i = 0; i < 21; i++)
            Arrays.fill(count[i], 2);
        HowManyNumberInOneLine[] points = new HowManyNumberInOneLine[21];
        for (int i = 0; i < 21; i++)
            points[i] = new HowManyNumberInOneLine((int) (Math.random() * 100), (int) (Math.random() * 100));
        if (null == points || points.length == 0) max = 0;
        else {
            for (int i = 0; i < points.length; i++) {
                Map<Double, Integer> k_num = new HashMap<Double, Integer>();//б�ʼ�����㹹��ֱ��Ϊ��б�ʵĵ�ĸ������������㣩
                double k = 0.0;
                int tempmax = 1;
                int coincideNum = 0;//��¼������غϵĵ�ĸ���
                for (int j = i + 1; j < points.length; j++) {
                    if (points[j].x - points[i].x == 0 && points[j].y - points[i].y == 0) {//������غ�
                        coincideNum++;
                        continue;
                    } else if (points[j].x - points[i].x != 0) {//ֱ����y��ƽ��
                        k = (double) (points[j].y - points[i].y) / (double) (points[j].x - points[i].x);
                    } else {
                        k = Double.MIN_VALUE;
                    }
                    int num = 2;
                    if (k_num.containsKey(k)) {
                        num = k_num.get(k);
                        k_num.put(k, ++num);
                    } else {
                        k_num.put(k, num);
                    }
                    tempmax = Math.max(tempmax, num);
                }
                max = Math.max(tempmax + coincideNum, max);
            }
            System.out.print(max);
        }
    }
}
